﻿// -----------------------------------------------------------------------
// <copyright file="BookFilterSimpleFactory.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.Domain.Factories
{
	#region Usings

	using MBOP.Core.Entities.Common;
	using MBOP.Core.Entities.Library;
	using MBOP.Core.FilterContexts;
	using MBOP.Core.Interfaces.Common;
	using MBOP.Domain.Filters;

	#endregion

	/// <summary>
	/// Provides methods to create book filters.
	/// </summary>
	public static class BookFilterSimpleFactory
	{
		/// <summary>
		/// Creates book filter by specific context.
		/// </summary>
		/// <param name="filterContext">The book filter context.</param>
		/// <returns>Specified book filter.</returns>
		public static IFilter<Book> CreateBookFilter(BookFilterContext filterContext)
		{
			IFilter<Book> result = null;

			switch (filterContext.FilterType)
			{
				case FilterType.All:
					{
						result = new AllBookFilter();
						break;
					}

				case FilterType.My:
					{
						result = new SubscriberBookFilter(filterContext);

						break;
					}

				case FilterType.Popular:
					{
						result = new PopularBookFilter(filterContext);

						break;
					}
			}

			return result;
		}
	}
}
